import { fileURLToPath, URL } from "node:url";
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
  server: {
    port: 5173,
    proxy: {
      "/api": {
        target: "http://localhost:3001",
        changeOrigin: true,
      },
      // 或者使用更通用的 Socket.io 路径代理
      "/socket.io": {
        target: "ws://localhost:3001",
        changeOrigin: true,
        ws: true, // 启用 WebSocket 代理
      },
    },
  },
});
